home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C++ / Applications / NeuroSim 1.0 / .h / CNeuralNet.h < prev    next >
Text File  |  1996-02-19  |  2KB  |  77 lines

  1. // ===========================================================================
  2. //    CNeuralNet.h                ©1996 Timo Eloranta
  3. // ===========================================================================
  4. //  An abstract neural net class - derived from LPeriodical to 
  5. //    receive a function call (SpendTime()) at regular intervals
  6.  
  7. #pragma once                        // Include this header only once
  8.  
  9. #include "CNeuron.h"
  10.  
  11. #include <LQueue.h>                    // PowerPlant queue class
  12. #include <LPeriodical.h>            // PowerPlant "repeater" class
  13.  
  14. class CNeuroSimPane;                // Forward class declaration
  15.  
  16. class CNeuralNet : public LPeriodical
  17. {
  18.     protected:
  19.         CNeuron        *mMatrix;        // Matrix of neurons (array)
  20.         
  21.         Uint16        mSize;            // The size of the matrix (mSize x mSize)
  22.         
  23.         LQueue        mLightQueue;    // A queue of the neurons 
  24.                                     // which are ready to light up
  25.                                     
  26.         Boolean        mDemoMode;        // Demo mode: ON or OFF ?
  27.  
  28.         CNeuroSimPane    *mPane;        // The pane which displays this net
  29.  
  30.         virtual void        InitMatrix( const SGenParams & inParams );
  31.         
  32.         virtual void        GenerateConnections( CNeuron & inNeuron,
  33.                                         const SGenParams & inParams ) const;
  34.                                         
  35.         virtual CNeuronPtr    GetRandomReceptor() const;
  36.         
  37.         Boolean                ValidLocation( Int16 inCol, Int16 inRow ) const;
  38.  
  39.     public:
  40.                             CNeuralNet( Uint16 inSize );
  41.         virtual                ~CNeuralNet() {};
  42.  
  43.         virtual CNeuronPtr    GetNeuron( Uint16 inCol, Uint16 inRow) const;
  44.                             
  45.         Boolean                DemoModeOn() const
  46.                             { return mDemoMode; };
  47.         void                ChangeDemoMode()
  48.                             { mDemoMode = (! mDemoMode); };
  49.                             
  50.         virtual void        SpendTime( const EventRecord &inMacEvent );
  51.         
  52.         virtual void        AddToLightQ( LLink * inNeuron );
  53.         virtual void        ProcessLightQ();
  54.         
  55.         virtual Uint16        GetNetSize() const
  56.                             { return mSize; };
  57.  
  58.         // Pure virtual. Concrete subclasses must override!
  59.         virtual void        CreateMatrix() = 0;                    
  60.  
  61.                 // --- Drawing related member functions --- //
  62.                             
  63.         virtual void        SetPane( CNeuroSimPane * inPane )
  64.                             { mPane = inPane; };
  65.  
  66.         virtual void        SetNeuronsDirty( const Rect & inRect ) const;
  67.         
  68.         virtual void        SetCenterPoints( Uint16 inOneOneXY, 
  69.                                              Uint16 inSquareSize) const;
  70.  
  71.         virtual void        RequestDraw() const;
  72.         
  73.         virtual void        DrawNeurons( const Rect & inOneOneRect, 
  74.                                          Uint16 inSquareSize) const;
  75.                                             
  76.         virtual void        DrawConnections() const;
  77. };